package priv.dajie.tzzq.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import priv.dajie.tzzq.dao.SteamMapper;
import priv.dajie.tzzq.model.QualityName;
import priv.dajie.tzzq.service.SteamService;
import priv.dajie.tzzq.spider.model.ItemInfo;
import priv.dajie.tzzq.spider.model.SellingInfo;

/**
 * @ClassName SteamServiceImpl
 * @Description
 * @Author dajie
 * @Date 2019/10/24 12:54 上午
 * @Version V1.0
 **/
public class SteamServiceImpl implements SteamService {

    @Autowired
    SteamMapper steamMapper;

    @Override
    public boolean addItem(SellingInfo sellingInfo) {
        boolean state = steamMapper.updateItem(sellingInfo);
        if (!state){
            state = steamMapper.addItem(sellingInfo);
        }
        return state;
    }

    @Override
    public Integer countItem(String steamName) {
        return steamMapper.getItemCount(steamName);
    }

    @Override
    public boolean addInfo(ItemInfo itemInfo) {
        return steamMapper.addInfo(itemInfo);
    }

    @Override
    public boolean updateInfo(ItemInfo itemInfo) {
        return steamMapper.updateInfo(itemInfo);
    }

    @Override
    public ItemInfo getInfo(ItemInfo itemInfo) {
        return steamMapper.getInfo(itemInfo);
    }

    @Override
    public ItemInfo getInfoById(String nameId){
        ItemInfo itemInfo = new ItemInfo();
        itemInfo.setId(nameId);
        return steamMapper.getInfo(itemInfo);
    }


    @Override
    public ItemInfo getInfoBySteamName(String steamName){
        ItemInfo itemInfo = new ItemInfo();
        itemInfo.setSteamName(steamName);
        return steamMapper.getInfo(itemInfo);
    }

    @Override
    public ItemInfo getInfoByQualityName(QualityName qualityName){
        ItemInfo itemInfo = new ItemInfo();
        itemInfo.setQualityName(qualityName);
        return steamMapper.getInfo(itemInfo);
    }

}
